package servlets;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import dto.OfertaDTO;

import business.LaCorunaDelegator;

/**
 * Servlet implementation class for Servlet: VerOFADxml
 *
 */
 public class VerOFADxml extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet {
   static final long serialVersionUID = 1L;
   private static final String OFAD_PAGE = "/WEB-INF/jsp/listado_ofads.jsp";
    /* (non-Java-doc)
	 * @see javax.servlet.http.HttpServlet#HttpServlet()
	 */
	public VerOFADxml() {
		super();
	}   	
	
	/* (non-Java-doc)
	 * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		LaCorunaDelegator delegator = LaCorunaDelegator.getInstance();
		String Ofadref= request.getParameter("ref"); 
		String url= delegator.getOFADxml(Ofadref);
		List<OfertaDTO> ofads= delegator.getListdoOFAD();
		request.setAttribute("ofads", ofads);
		getServletContext().getRequestDispatcher(OFAD_PAGE).forward(request, response);
	}  	
	
	/* (non-Java-doc)
	 * @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}   	  	    
}